package likou.tanxin;

import java.util.Arrays;
import java.util.Comparator;

/**
 * @author: Tangxz
 * @email: 1171702529@qq.com
 * @cate: 2020/11/18 09:24
 */
public class _1029 {
    public int twoCitySchedCost(int[][] costs) {
        Arrays.sort(costs, new Comparator<int[]>() {
            @Override
            public int compare(int[] o1, int[] o2) {
                return o1[0] - o1[1] - o2[0] + o2[1];
            }
        });
        int daan = 0;
        for (int i=0;i<costs.length/2;i++){
            daan+=costs[i][0];
        }
        for (int i=costs.length/2;i<costs.length;i++){
            daan+=costs[i][1];
        }
        return daan;
    }
}
